#!/usr/bin/env bash

# ----------- 请根据实际情况，修改如下配置 ------------ #

#ctc目录
CTC_DIR=/root/ctc-docker/html/ctc

# ------------ @@@ 以下内容，非专业人士请勿修改，新手请远离！ @@@ ------------- #

#更新源码
cd ${CTC_DIR} && git pull

ctc_config_php=${CTC_DIR}/config/config.php

static_version=$(date +%s)

#更新静态资源版本号
sed -i "s/\$config\['static_version'\].*/\$config['static_version'] = '${static_version}';/g" ${ctc_config_php}

docker exec -i ctc-php bash <<'EOF'

#切换到ctc目录
cd /var/www/html/ctc || exit

#安装依赖包
composer install --no-dev
composer dump-autoload --optimize

#数据迁移
vendor/bin/phinx migrate

#程序升级
php console.php upgrade

exit
EOF

echo -e "\n------ upgrade finished -------\n"
